<?php
class SQL{
	private static $instance = null;
	private $conn = null;
	
	private function SQL()
	{
		$dns = 'mysql:dbname=web_semantique;host=localhost';
		$user = 'root';
		$password = '';
		$this->conn = new PDO($dns, $user, $password);
		$this->conn->exec('SET NAMES \'UTF8\'');
	}
	
	public static function getInstance()
	{
		if(self::$instance == null)
			self::$instance = new SQL();
		
		return self::$instance;
	}
	
	public function query($req)
	{
		$res = $this->conn->query($req);
		$res = $res->fetchall();
		return $res;
	}
	
	public function exec($req)
	{
		$this->conn->exec($req);
	}
	public function lastInsertId()
	{
		$this->conn->lastInsertId();
	}
}
?>